<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- 
        Copyright 2011 Google Inc.
         
        This program is free software; you can redistribute it and/or
        modify it under the terms of the GNU General Public License
        as published by the Free Software Foundation; either version 2
        of the License, or (at your option) any later version.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
    -->
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
    
    <xsl:template match="/">
      <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
        <xsl:apply-templates select="videos"/>
      </urlset>
    </xsl:template>
    
    <xsl:template match="videos">
      <xsl:for-each select="video">
        <xsl:apply-templates select="."/>
      </xsl:for-each>
    </xsl:template>
    
    <xsl:template match="video">
			<xsl:element name="url" namespace="http://www.sitemaps.org/schemas/sitemap/0.9">
			  <xsl:element name="loc" namespace="http://www.sitemaps.org/schemas/sitemap/0.9">
  			  <xsl:value-of select="url"/>
        </xsl:element>
			  <xsl:element name="video:video" namespace="http://www.google.com/schemas/sitemap-video/1.1">
          <xsl:element name="video:thumbnail_loc" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="image"/></xsl:element>			  
			  	<xsl:element name="video:title" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="title"/></xsl:element>
					<xsl:element name="video:description" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="description"/></xsl:element>
					<xsl:element name="video:content_loc" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="file"/></xsl:element>
					<!-- <video:player_loc allow_embed="yes" autoplay="ap=1"></video:player_loc> -->
					<xsl:if test="duration">
					  <xsl:element name="video:duration" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="duration"/></xsl:element>
					</xsl:if>
					<xsl:if test="expiration">
            <xsl:element name="video:expiration_date" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="expiration"/></xsl:element>
          </xsl:if>
					<xsl:element name="video:publication_date" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="publication_date"/></xsl:element>
					<xsl:if test="restrictions">
            <xsl:element name="video:restriction" namespace="http://www.google.com/schemas/sitemap-video/1.1">
              <xsl:attribute name="relationship">allow</xsl:attribute>
              <xsl:value-of select="restrictions"/>
            </xsl:element>
          </xsl:if>
					<xsl:if test="tags/tag[1]">
					  <xsl:for-each select="tags/tag">
					     <xsl:element name="video:tag" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="."/></xsl:element>
					  </xsl:for-each>
					</xsl:if>
					<xsl:if test="family_friendly">
            <xsl:element name="video:family_friendly" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="family_friendly"/></xsl:element>
          </xsl:if>
          <xsl:if test="category">
            <xsl:element name="video:category" namespace="http://www.google.com/schemas/sitemap-video/1.1"><xsl:value-of select="category"/></xsl:element>
          </xsl:if>
					<!-- <video:rating></video:rating> -->
					<!-- <video:view_count></video:view_count> -->
					<!-- <video:gallery_loc title=""></video:gallery_loc> -->
					<!-- <video:price currency=""></video:price> -->
					<!-- <video:requires_subscription></video:requires_subscription> -->
					<!-- <video:uploader info=""></video:uploader> -->
				</xsl:element>
			</xsl:element>
    </xsl:template>
    
</xsl:stylesheet>